package com.example.demo3.config;


/*
* 1.创建异常类，添加@RestControllerAdvice
创建异常返回方法，添加@ExceptionHandler(Exception.class)
* */

import com.example.demo3.util.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result allException(Exception e) {
        return new Result(501,"全局异常",e.getMessage());
    }
}
